package com.hxminer.hxwebs.utils;

import com.hxminer.hxwebs.enmus.ResultEnum;
import com.hxminer.hxwebs.model.Result;

/**
 * Author YRG
 * Created by on 2018/5/8.
 * Describe
 */
public class ResultUitl {

    public static Result success(Object object) {
        Result result = new Result();
        result.setMsg("成功！");
        result.setCode(0);
        result.setData(object);
        return result;
    }

    public static Result success(Object object, String msg) {
        Result result = new Result();
        result.setMsg(msg);
        result.setCode(0);
        result.setData(object);
        return result;
    }


    public static Result success() {
        return success(null);
    }

    public static Result success(ResultEnum resultEnum, Object object) {
        Result result = new Result();
        result.setMsg(resultEnum.getMsg());
        result.setCode(resultEnum.getCode());
        result.setData(object);
        return result;

    }

    public static Result success(ResultEnum resultEnum) {
        Result result = new Result();
        result.setMsg(resultEnum.getMsg());
        result.setCode(resultEnum.getCode());
        result.setData(null);
        return result;

    }



    public static Result error(Integer code, String msg) {
        Result result = new Result();
        result.setCode(code);
        result.setMsg(msg);
        return result;
    }

    public static Result error(ResultEnum resultEnum) {
        Result result = new Result();
        result.setCode(resultEnum.getCode());
        result.setMsg(resultEnum.getMsg());
        return result;
    }
}
